<admintpl file="header" />
<style type="text/css">
	#myModal{
		width: 350px;
		top:20%;
		left: 50%;
	}

</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('Customer/index')}">客户列表</a></li>
			<li><a href="{:U('Customer/add')}">添加客户</a></li>
		</ul>
        <form class="well form-search" method="post" action="{:U('customer/index')}">
            用户名:
            <input type="text" name="customer_name" style="width: 100px;" value="{$customer_name}" placeholder="请输入用户姓名">
            手机号:
            <input type="text" name="mobile" style="width: 100px;" value="{$mobile}" placeholder="用户手机号">
            客户状态：
            <select name="status" style="width:150px;">
            	<option value="-1">全部</option>
            	<foreach name="customer_status_list" item="vo" >
            	    <option value="{$vo['key']}" <if condition="$customer_status eq $vo['key']">selected</if>>{$vo['value']}</option>
            	</foreach>
            </select>
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn" href="{:U('customer/index')}">清空</a>
        </form>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="50">ID</th>
					<th>姓名</th>
					<th>手机号</th>
					<th>账户余额</th>
					<th>最后充值时间</th>
					<th>客户状态</th>
					<th>客户类型</th>
					<th>添加时间</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody>
		
				<foreach name="list" item="vo">
				<tr>
					<td>{$vo.id}</td>
					<td><a href="{:U('Customer/customer_profiles',array('customer_mobile'=>$vo['mobile']))}">{$vo.customer_name}</a></td>
					<td>
						{$vo.mobile}
					</td>
					<td style="text-align:right">{:money_number_format($vo['money'])}</td>
					<td>{$vo['last_recharge_time']}</td>
					<td>{:getStatusValue('customer_status',$vo['status'])}&nbsp;<if condition="$vo['status'] eq '0'"><a  style="padding:3px 8px" data-id="{$vo['id']}" data-value="{$vo['customer_name']}" class="btn btn-success customer-active" data-toggle="modal" data-target="#myModal">激活</a></if></td>
					<td>{:getCustomerType($vo['customer_type_id'])}</td>
				    <td>{:substr($vo['create_time'],0,16)}</td>
					<td>
					    <a href="{:U('Event/index',array('customer_mobile'=>$vo['mobile']))}" target="_blank">赛事</a>|<a href="{:U('Customer/edit',array('id'=>$vo['id']))}">编辑</a>|<a target="_blank" href="{:U('Finance/recharge',array('mobile'=>$vo['mobile']))}">充值</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>

	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					提示信息
				</h4>
			</div>
			<div class="modal-body" style="text-align:center;">
			    确定要激活客户（<span style="color:green;" id="customer-name"></span>）吗？
			</div>
			
			<div class="modal-footer">
				<input name="customer_id" id="customer_id" type="hidden" value="">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消
				</button>
				<button type="button" id="btn-active" class="btn btn-primary">
					确定
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
        $(".customer-active").click(function(){
        	$("#customer_id").val($(this).attr("data-id"));
        	var customer_name = $(this).attr("data-value");
        	$("#customer-name").text(customer_name);
        })

        //点击确定按钮
        $("#btn-active").click(function(){
        	var id  = $("#customer_id").val();
        	var url = "{:U('customer/customer_active')}";
        	$.ajax({  
	            type     : "GET",  
	            url      : url,  
	            data     : {id:id},  
	            dataType : "json",  
	            async    : false,
	            success  :  function(data){  
	                            if(data.status == 1){
	                            	window.location.reload();
	                            }
	                        }  
            });  
        })
	</script>
</body>
</html>